<template>
	<div>
		<el-form :inline="true" :model="query" label-width="130px" size="small">
			<el-row>
				<el-form-item label="企业名称：" class="query-form-item">
					<span style="display: inline-block; width: 220px">{{this.$route.query.enterprisename}}</span>
				</el-form-item>
				<el-form-item label="统一信用代码：" class="query-form-item">
					<span style="display: inline-block; width: 220px">{{this.$route.query.registrationnumber}}</span>
				</el-form-item>
				<el-form-item label="联系人：" class="query-form-item">
					<span style="display: inline-block; width: 200px">{{this.$route.query.usernick}}</span>
				</el-form-item>
			</el-row>
			<el-row>
				<el-form-item label="联系电话：" class="query-form-item">
					<span style="display: inline-block; width: 220px">{{this.$route.query.usermobile}}</span>
				</el-form-item>
				<el-form-item label="扣税总额：" class="query-form-item">
					<span style="display: inline-block; width: 220px">{{this.$route.query.taxtotal}}</span>
				</el-form-item>
				<el-form-item label="注册时间：" class="query-form-item">
					<span style="display: inline-block; width: 200px">
						<i class="el-icon-time" v-if="this.$route.query.userregisttime != null"></i>
					    <span v-if="this.$route.query.userregisttime != null">{{this.$route.query.userregisttime | formatDateStr("yyyy-MM-dd hh:mm:ss")}}</span>
					    <span v-else>无</span>
					</span>
				</el-form-item>
			</el-row>
		</el-form>

		<el-form :inline="true" :model="query" label-width="130px" size="small">
			<!-- 申请商城账号查询 -->
			<el-form-item class="query-form-item" label="收入项：">
				<el-select v-model="query.taxtype" placeholder="请选择状态" @change="onSubmit" clearable>
					<el-option label="全部" value=''> </el-option>
					<el-option label="订单收益扣税" value='1'> </el-option>
					<el-option label="货款扣税" value='2'> </el-option>
				</el-select>
			</el-form-item>
			<!-- 申请生成时间 -->
			<el-form-item>
				<el-date-picker v-model="createTime" unlink-panels type="datetimerange" :picker-options="pickerOptions"
					range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" align="left"
					format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
					:default-time="['00:00:00','23:59:59']" @change="dateChange"></el-date-picker>
			</el-form-item>

			<!-- 查询框 -->
			<el-form-item>
				<el-button type="primary" icon="el-icon-refresh" @click="onRest" size="small"></el-button>
				<el-button type="primary" icon="el-icon-search" @click="onSubmit" size="small">查询</el-button>
			</el-form-item>
		</el-form>
		<!-- table表单 -->
		<el-table ref="multipleTable" v-loading="loading" :data="tableData"
			:header-cell-style="{ background: '#F4F4F5', color: '#606266' }">
			<el-table-column type="index" label="序号" width="55" align="center" fixed></el-table-column>

			<el-table-column label="收入项" prop="taxtype" align="center"></el-table-column>
			<el-table-column label="收入额" prop="pretax" align="center"></el-table-column>
			<el-table-column label="税点" prop="taxpoint" align="center"></el-table-column>
			<el-table-column label="来源" prop="belongdata" align="center"></el-table-column>
			<el-table-column label="扣税金额" prop="taxquota" align="center"></el-table-column>
			<el-table-column label="扣税时间" prop="id" align="center">
				<template slot-scope="scope">
				    <i class="el-icon-time" v-if="scope.row.createtime != null"></i>
					<span v-if="scope.row.createtime != null">{{ scope.row.createtime | formatDateStr("yyyy-MM-dd hh:mm:ss")}}</span>
					<span v-else>无</span>
				</template>
			</el-table-column>
		</el-table>

		<el-pagination class="pagination-container" background :page-size="query.pageSize"
			@size-change="handleSizeChange" @current-change="handleCurrentChange"
			layout="total,sizes,prev, pager, next, jumper" :current-page="this.query.currentPage"
			:page-sizes="[5, 10, 20, 30, 50]" :total="totalNumber"></el-pagination>
	</div>
</template>
<script>
	import {
		BASE_URL
	} from "../../config/app";
	import {
		getMbUserProfitTax
	} from "../../api/fundsManagement";
	export default {
		data() {
			return {
				tableData: [], //列表集合
        createTime:[],
				pickerOptions: {
					//快速选择日期
					shortcuts: [{
							text: "最近一周",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 7
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近一个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 30
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近三个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 90
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近六个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 180
								);
								picker.$emit("pick", [start, end]);
							}
						}
					]
				},
				query: {
					currentPage: 1,
					pageSize: 5,
					starttime: "", //开始时间
					endtime: "", //结束时间
					taxtype:"",
					userid:this.$route.query.userid
				},
				companyData: {},
				totalNumber: 0,
				loading: false,
			};
		},
		methods: {
			/*日期选择事件*/
			dateChange(val) {
				if (val == null) {
					this.query.starttime = "";
					this.query.endtime = "";
				} else {
					this.query.starttime = val[0];
					this.query.endtime = val[1];
					this.query.currentPage = 1;
				}
				this.getList();
				// console.log(this.query);
			},
			//刷新
			onRest() {
				this.createTime = [],
				this.query= {
					currentPage: 1,
					pageSize: 5,
					starttime: "", //开始时间
					endtime: "", //结束时间
					taxtype:"",
					userid:this.$route.query.userid
				},
				this.getList()
			},
			// 列表数据获取
			getList() {
				this.loading = true;
				console.log(this.query)
				getMbUserProfitTax(this.query)
					.then((data) => {
						if (data.code != 0) {
							this.$message.error(response.message);
							this.loading = false;
							return false;
						}
						this.tableData = data.data.list || [];
						this.totalNumber = data.data.totalNumber || 0;
						// console.log(this.tableData)
						setTimeout(() => {
							this.loading = false;
						}, 300);
					})
					.catch((err) => {
						this.loading = false;
						this.tableData = [];
					});
			},
      //查询
			onSubmit() {
				this.query.currentPage = 1;
				this.getList();
				// console.log('submit!');
			},
			handleCurrentChange(val) {
				this.query.currentPage = val;
				//scrollTo(0, 800);
				this.getList();
			},
			handleSizeChange(val) {
				this.query.pageSize = val;
				this.getList();
			},
		},

		mounted() {
		    this.getList();
		},
		created() {
			
		},
	};
</script>
